home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus Leser 15 / Amiga Plus Leser CD 15.iso / Tools / Development / yacas_alg / yacas_morphos / share / yacas / html.rep / code.ys < prev   
Encoding:
Text File  |  2002-03-13  |  3.3 KB  |  209 lines

  1.  
  2. /* code to generate html */
  3.  
  4.  
  5. /* Global defines */
  6. anchor:={};
  7. anchor["0"]:="A";
  8. anchor["NAME"]:="";
  9.  
  10. link:={};
  11. link["0"]:="A";
  12. link["HREF"]:="";
  13.  
  14. frameset:={};
  15. frameset["0"]:="FRAMESET";
  16. frameset["BORDER"]:="0";
  17.  
  18. frame:={};
  19. frame["0"]:="FRAME";
  20.  
  21. caption:={};
  22. caption["0"]:="CAPTION";
  23.  
  24. table:={};
  25. table["0"]:="TABLE";
  26.  
  27. form:={};
  28. form["0"]:="FORM";
  29.  
  30. textarea:={};
  31. textarea["0"]:="TEXTAREA";
  32.  
  33. textfield:={};
  34. textfield["0"]:="INPUT";
  35. textfield["TYPE"]:="TEXT";
  36.  
  37. button:={};
  38. button["0"]:="INPUT";
  39. button["TYPE"]:="SUBMIT";
  40.  
  41. bullets:={};
  42. bullets["0"]:="UL";
  43.  
  44. bullet:={};
  45. bullet["0"]:="LI";
  46.  
  47. newline:="
  48. ";
  49. Gt():=">";
  50. Lt():="<";
  51.  
  52.  
  53.  
  54.  
  55. HtmlNewParagraph():= (newline : "<P>" : newline);
  56.  
  57. HtmlTitle(title):=
  58. [
  59.   "<HEAD><TITLE>" : title : "</TITLE></HEAD>";
  60. ];
  61.  
  62. HtmlAnchor(name):=
  63. [
  64.   anchor["NAME"]:=name;
  65.   HtmlTag(anchor,"");
  66. ];
  67. Bodied("HtmlAnchor",60000);
  68.  
  69. HtmlTable(cellpadding,width,body):=
  70. [
  71.   table["CELLPADDING"]:=String(cellpadding);
  72.   table["WIDTH"]:=width;
  73.   HtmlTag(table,body);
  74. ];
  75.  
  76. Bullets(list):=HtmlTag(bullets,list);
  77. Bullet (list):=HtmlTag(bullet ,list);
  78.  
  79.  
  80. HtmlCaption(title):=
  81. [
  82.  HtmlTag(caption,title);
  83. ];
  84.  
  85. HtmlForm(action,body):=
  86. [
  87.   form["METHOD"]:="GET";
  88.   form["ACTION"]:=action;
  89.   HtmlTag(form,body);
  90. ];
  91.  
  92.  
  93. HtmlTextArea(name,width,height,body) :=
  94. [
  95.   textarea["NAME"]:=name;
  96.   textarea["COLS"]:=String(width);
  97.   textarea["ROWS"]:=String(height);
  98.   HtmlTag(textarea,body);
  99. ];
  100.  
  101. HtmlTextField(name,size,value):=
  102. [
  103.   textfield["NAME"]:=name;
  104.   textfield["SIZE"]:=String(size);
  105.   textfield["VALUE"]:=value;
  106.   HtmlTag(textfield,"");
  107. ];
  108.  
  109. HtmlSubmitButton(name,value):=
  110. [
  111.   button["NAME"]:=name;
  112.   button["VALUE"]:=value;
  113.   HtmlTag(button,"");
  114. ];
  115.  
  116.  
  117. HtmlLink(description,file,tag,target):=
  118. [
  119.   If(tag != "",
  120.     link["HREF"]:= file : "#" : tag,
  121.     link["HREF"]:= file);
  122.     
  123.   link["TARGET"] :=target;
  124.   HtmlTag(link,description);
  125. ];
  126.  
  127. HtmlFrameSetRows(columns,body):=
  128. [
  129.   frameset["COLS"]:="";
  130.   frameset["ROWS"]:=columns;
  131.   HtmlTag(frameset,body);
  132. ];
  133.  
  134. HtmlFrameSetCols(columns,body):=
  135. [
  136.   frameset["COLS"]:=columns;
  137.   frameset["ROWS"]:="";
  138.   HtmlTag(frameset,body);
  139. ];
  140.  
  141. HtmlFrame(source,name):=
  142. [
  143.   frame["SRC"]:=source;
  144.   frame["NAME"]:=name;
  145.   HtmlTag(frame,"");
  146. ];
  147.  
  148.  
  149. /* export a html tag type, using the specifications in the
  150.    tags assoc list.
  151.    */
  152. HtmlTag(tags,content):=
  153. [
  154.   Local(result,tag);
  155.   result:="<" : tags["0"];
  156.   ForEach(tag,AssocIndices(tags))
  157.   [
  158.     If (tag != "0" And tags[tag] != "",
  159.        result:= result : " " : tag : "=" : "\"" : tags[tag] : "\""
  160.        ); 
  161.   ];
  162.   
  163.   result:= result : ">" : newline :
  164.            content : newline :
  165.            "</" : tags["0"] : ">" : newline;
  166.   
  167.   result;
  168. ];
  169.  
  170. /* output directory management */
  171. htmldir:="";
  172. SetHtmlDirectory(dir):= [htmldir:=dir;];
  173. HtmlFile(file) := [htmldir : file;];
  174.  
  175.  
  176. /* loading and saving site info */
  177. site:={};
  178. ClearSite() := [site:={};];
  179. LoadSite():=
  180. [
  181.   FromFile("siteall")
  182.   [
  183.     site:=Read();
  184.   ];
  185. ];
  186.  
  187. SaveSite():=
  188. [
  189.   ToFile("siteall")
  190.   [
  191.     Write(site);
  192.     WriteString(";");
  193.   ];
  194. ];
  195.  
  196. MySQLQuery(pidstr,string):=
  197. [
  198.   Local(result);
  199.   ToFile("sqlin":pidstr) WriteString(string);
  200.   SystemCall("mysql mysql < ":"sqlin":pidstr:" > sqlout":pidstr);
  201.   SystemCall(FindFile("tools/mysqlstubs"):" sqlout":pidstr:" sqlout_":pidstr);
  202.   result:= FromFile("sqlout_":pidstr)Read();
  203.   SystemCall("rm -rf sqlin":pidstr);
  204.   SystemCall("rm -rf sqlout":pidstr);
  205.   SystemCall("rm -rf sqlout_":pidstr);
  206.   result;
  207. ];
  208.  
  209.